package com;

import java.io.IOException;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import connection.DBConnection;

/**
 * Servlet implementation class EditRegisterServlet2
 */
@WebServlet("/EditRegisterServlet2")
public class EditRegisterServlet2 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EditRegisterServlet2() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		DBConnection dbc=new DBConnection();	
		 Connection con=dbc.getNewConnection();
	
		 Statement st = null;
		 ResultSet rs = null;

		 PrintWriter out = response.getWriter();
		String a =request.getParameter("pan");
		String a0 = request.getParameter("or");
      String a1 = request.getParameter("mv");
      String a2 = request.getParameter("ad");
      String a3 = request.getParameter("ct");
      String a4 = request.getParameter("ds");
      String a5 = request.getParameter("st");
      String a6 = request.getParameter("pn");
      String a7 = request.getParameter("pr");
      String a8 = request.getParameter("desg");
      try 
		{
			st = con.createStatement();
		}
		catch (SQLException e) 
		{
			e.printStackTrace();
		}
		
		String updatecust = "update register2 set org_name='"+ a0 + "', mvat='"+ a1 + "',address='"+ a2 + "',city='"+ a3 + "',dist='"+ a4 + "',state='"+ a5 + "',pin='"+ a6 + "',autho_person='"+ a7+ "',designation='"+ a8+ "'";
		try 
		{
			
			int i=st.executeUpdate(updatecust);
			
			if(i>0){
			out.print("<font color=#’43b200′><b><center>Details saved successfully....!!</center></b></font>");
			}
			else
               out.print("Sorry..!! Got an exception.");
		}
		catch (SQLException e) 
		{
			e.printStackTrace();
		}
		
		
	}

}
